#!/usr/local/bin/perl
push @INC, "./";

#needed library
require(multiwordnet_ram);

use strict;

my $lang = "english";
my $lemma = "arrive";

#my $lang = "pwn"; # lang could be italian or english
#my $lemma = "home";   # language lemma
#my $id = "n#08440931"; # identifier ver. WN 1.6. The format maus be pos#offset
#my $id = "n#08491027"; # identifier ver. WN 3.0. The format maus be pos#offset
my $id;

#my $lang = "spanish";
#my $lemma ="morada";

#setting data archive path
#set_mwn_path("./mwndata_edit/");
#set_mwn_path("./mwndata3.0/");
set_mwn_path("mwndata1.4.3");

#TEST
my @ids = get_synsets($lemma,"v",$lang);
if ($#ids > 0) {
    $id = $ids[2];
    print 'get_synsets("'.$lemma.'","","'.$lang.'") = ' . join(" ", @ids) . "\n";
    print 'get_lemmas("'.$id.'","'.$lang.'") = ' . join(" ", get_lemmas($id,$lang)) . "\n";
    print 'get_gloss("'.$id.'","'.$lang.'") = ' . get_gloss($id,$lang) . "\n";
    print 'get_relation_types("'.$id.'")) = ' . join(" ", get_relation_types($id)) . "\n";
    print 'get_relation_synsets("'.$id.'","hypernym")) = ' . join(" ", get_relation_synsets($id,"hypernym")) . "\n";
    print 'get_relation_synsets_ricorsive("'.$id.'","hypernym")) = ' . join(" ", get_relation_synsets_ricorsive($id,"hypernym")) . "\n";
    print 'get_synset_semfield("'.$id.'")) = ' . join(" ", get_synset_semfield($id)) . "\n";
    print 'get_synset_sumo("'.$id.'")) = ' . join(" ", get_synset_sumo($id)) . "\n";
    
    print 'get_semfields() = ' . get_semfields(). "\n";
    
    my @list_synsets = get_synsets($lemma,"",$lang);
    for my $synset_id (@list_synsets) {
	my @list_hype_synsets = get_relation_synsets_ricorsive($synset_id,"hypernym");
	for my $target_id (@list_hype_synsets) {
	    print $target_id ."\t". join(" ",get_lemmas($target_id,$lang)) ."\n";
	}
    }
}
exit;

#save domain lemmas into files
my @semfields = get_semfields();
foreach my $sem (@semfields) {
	print $sem . " ... ./fileout/".$sem.".lem\n";
	open (OUT, "> ./fileout/".$sem.".lem");
	my $lemmas = get_lemma_semfield($sem);
	$lemmas =~ s/GAP!//g;
	$lemmas =~ s/PSEUDOGAP!//g;
	$lemmas =~ s/[\s|_]+/ /g;
	
	print OUT $lemmas;
	close(OUT);
}


